package com.hyt.it.ogt.kq.common.gov.enums.admission;

import com.hyt.it.ogt.kq.common.gov.constant.admission.AdmissionTicketTemplateCode;

import java.util.Arrays;
import java.util.Objects;

/**
 * 准考证性别枚举
 *
 * @author zhoumiao
 * @since 2023/2/8 13:47
 **/
public enum AdmissionSexEnum {
    MAN("0", "男"),
    WOMAN("1", "女")
    ;

    String code;
    String text;

    AdmissionSexEnum(String code, String text) {
        this.code = code;
        this.text = text;
    }

    public String getCode() {
        return code;
    }

    public String getText() {
        return text;
    }

    /**
     * 是否证件类型code
     *
     * @param code
     * @return
     */
    public static boolean isSex(String code) {
        return AdmissionTicketTemplateCode.SEX.equals(code);
    }

    /**
     * 转换证件类型为中文
     *
     * @param value
     * @return
     */
    public static String convert(String value) {
        return Arrays.stream(AdmissionSexEnum.values())
                .filter(admissionSexEnum -> Objects.equals(admissionSexEnum.getCode(), value))
                .findFirst()
                .map(AdmissionSexEnum::getText)
                .orElse("");

    }
}
